package main

import "fmt"

func MakeSlice() {
	//var slice1 []int = []int{1, 2, 3}
	slice2 := []int{4, 5, 6}
	for index, item := range slice2 {
		fmt.Println(index, " : ", item)
	}
}
func MakeSlice2() {
	var slice1 []int = make([]int, 5)
	slice1 = append(slice1, 1)
	slice1 = append(slice1, 2, 3, 4, 5)
	for index, item := range slice1 {
		fmt.Println(index, " : ", item)
	}
}
func CropSlice() {
	var slice []int = []int{1, 2, 3, 4, 5, 6}
	s2 := slice[1:4]
	fmt.Println(s2)
}
func GetLenOfSlice() {
	var slice []int = []int{1, 2, 3, 4, 5, 6}
	fmt.Println(len(slice))

	var slice2 []string = []string{"hello", "world", "hi"}
	fmt.Println(len(slice2))
}
func TraverseSlice() {
	var slice1 []int = []int{1, 2, 3, 4, 5, 6}
	for index, item := range slice1 {
		fmt.Println(index, " : ", item)
	}
}
func AssignSlice() {
	var slice []int = make([]int, 10)
	for i := 0; i < 10; i++ {
		slice[i] = i + 1
	}
	for index, item := range slice {
		fmt.Println(index, " : ", item)
	}
}
func CopySlice() {
	var s1 []int = []int{1, 2, 3, 4, 5}
	var s2 []int = make([]int, 3)
	copy(s2, s1)
	for index, item := range s2 {
		fmt.Println(index, " : ", item)
	}
	fmt.Println(len(s2))
}

func MakeNilSlice() {
	var s []int
	s = append(s, 1)
	s = append(s, 2, 3, 4)
	for _, item := range s {
		fmt.Println(item)
	}
}
func AliasSlice() {
	type IntSlice []int
	var s IntSlice
	s = append(s, 1)
	s = append(s, 2, 3, 4)
	for _, item := range s {
		fmt.Println(item)
	}
}
